<?php 
ArrowController::importModel("org.arrowplatform.model.IArrowModelAction");

class ArrowAbstractUIAction extends ArrowTagContainer implements IArrowModelAction{

	const STANDARD_CONTROLER = "/controller::actionRouter";
	
	protected $arguments;
	private $id;
	
	public function configure(){
		$this->addProperties(array(
			"name" => null,
			"id" => null,
			"type" => null,
			"description" => false,
			"checkAccess" => true,
			"ctrl-connected" => false,
			"class" => false
			
		));
		$this->addRequiredProperties(array("id", "name", "type"));
		$this->setContentCodeKept(true);
		//$this->setDisplay(false);
		
	}
	public function init(){
		$this->arguments = array();
		foreach($this->getChildren("ArrowCtrlParam") as $param){
			$this->arguments[$param->getName()] = $param->getValue();
		}
		$this->id = $this->getProperty("id");
		
	}
	
	public function getId(){
		return $this->id;
	}
	public function getName(){
		return $this->getProperty("name");
	}
	
	public function isAllowed(){
		throw new ArrowCoreException( array("UI Action doesn't return isAllowed!") );
	}
	public function getDescription(){
		return $this->getProperty("description");
	}
	public function getType(){
		return $this->getProperty("type");
	}
	protected function generateClass(){
		$str = 'class="'.self::CTRL_NAMESPACE.'-action ';
		$ex = explode( ":", $this->getId() ) ;
		if( count($ex) == 2 ) $id = $ex[1] ;
		else $id = $ex[0] ;
		$str.= self::CTRL_NAMESPACE.'-action-'.$id." ";
		$str.= self::CTRL_NAMESPACE.'-action-type-'.$this->getType("type");
		$class = $this->getProperty("class");
		if($class)
			$str.= " ".$class;
		return $str."\"";
	}
	
	protected function generateSelector(){
		return ".".self::CTRL_NAMESPACE.'-action-type-'.$this->getType("type");
	}
	
	
	public function generateOutputCode(){
		return $this->generateBlockStartCode().$this->generateBlockEndCode();
	}
	
	public function generateBlockStart(){
		return $this->generate();
	}
	
	public function generateBlockEnd(){
		return "";	
	}
	
	
} 
?>